package hottargui.standard;

import hottargui.framework.*;

public class StandardEndTurnState implements TarguiState {

	Game gameContext;
	
	public StandardEndTurnState(Game game)
	{
		this.gameContext = game;
	}
	
	public boolean buy(int count, Position deploy) throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public State getState() {
		return State.endTurn;
	}

	public boolean move(Position from, Position to, int count)
			throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public void newGame() throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public void rollDie() throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public PlayerColor turnCard() throws IllegalActionException {
		TurnSequenceStrategy tss = gameContext.getGameObjectServer().getTurnSequenceStrategy();
		GameData gd = gameContext.getGameObjectServer().getGameData();
		
		if ( tss.playersLeftInTurn() == 0 )
		{
			gameContext.setState(gameContext.getFactory().getEndRoundState(gameContext));
			return gd.getPlayerInTurn().getColor(); // TODO: ???
		}
		else
		{
			gameContext.setState(gameContext.getFactory().getMoveState(gameContext));
			return gd.setPlayerInTurn(tss.nextPlayer());
		}
	}

	public PlayerColor getWinner() throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

}
